/********************************** (C) COPYRIGHT *******************************
* File Name          : smo.h
* Author             : nx666
* Version            : V1.0.0
* Date               : 2023/07/29
* Description        : 滑膜观测器接口在这里声明接口.
*******************************************************************************/
#ifndef __SMO_H
#define __SMO_H

#ifdef __cplusplus
extern "C" {
#endif

#include "common_type.h"
#include "module_config.h"
#include "pid.h"
#include "pll.h"
#include "fiter.h"

/**********************************宏定义区******************************/


/******************************* *类型定义区******************************/


/******************************* *类型定义区******************************/


typedef struct smo {  
                  _iq  Valpha;    // Input: Stationary alfa-axis stator voltage 
 
                  _iq  Ealpha;   // Variable: Stationary alfa-axis back EMF 
 
                  _iq  Zalpha;      // Output: Stationary alfa-axis sliding control 
 
                  _iq  Gsmopos;    // Parameter: Motor dependent control gain 

                  _iq  Gsmopos1;    // Parameter: Motor dependent control gain
 
                  _iq  EstIalpha;   // Variable: Estimated stationary alfaaxis stator current 
 
                  _iq  Fsmopos;    // Parameter: Motor dependent plant matrix 

                  _iq  Fsmopos1;    // Parameter: Motor dependent plant matrix
 
                  _iq  Vbeta;    // Input: Stationary beta-axis stator voltage 
 
                  _iq  Ebeta;   // Variable: Stationary beta-axis back EMF 
 
                  _iq  Zbeta;      // Output: Stationary beta-axis sliding control 
 
                  _iq  EstIbeta;    // Variable: Estimated stationary beta-axis statorcurrent 
 
                  _iq  Ialpha;   // Input: Stationary alfa-axis stator current 
 
                  _iq  IalphaError; // Variable: Stationary alfaaxis current error                 
 
                  _iq  Kslide;     // Parameter: Sliding control gain 
                  _iq  Kslide1;     // Parameter: Sliding control gain 
 
                  _iq  Ibeta;   // Input: Stationary beta-axis stator current 
 
                  _iq  IbetaError;  // Variable: Stationary betaaxis current error                 
 
                  _iq  Kslf;       // Parameter: Sliding control filter gain 
 
                  _iq  Theta;     // Output: Compensated rotor angle 
                  _iq  E0;

                  _iq  EalphaLpf;

                  _iq  EbetaLpf;


                pll_   *pll;
                FITER_movingAverage_ *fiterAlpha;
                FITER_movingAverage_ *fiterBeta;
                 void  (*calc)(struct smo*, _iq, _iq, _iq, _iq); // Pointer to calculation function  
                 _iq   (*getTheta)(struct smo*);
                 _iq   (*getOmega)(struct smo*);
 } smo_;

 /*********************************************************************
 * @fn      smoCreate
 *
 * @brief   smo构造函数，
 *              void
 *
 * @return  smo_ *，成功  NULL，失败
 *          
 */
smo_ * smoCreate(void);

#ifdef __cplusplus
}
#endif

#endif /*__SMO_H */